home *** CD-ROM | disk | FTP | other *** search
/ 3D Games - Real-time Rend…ng & Software Technology / 3D Games - Real-time Rendering & Software Technology.iso / flysdk / util / flyPlugin / Cstm3Dlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-02-20  |  3.4 KB  |  156 lines

  1. // cstm2dlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "flyplugin.h"
  6. #include "cstm3dlg.h"
  7. #include "flypluginaw.h"
  8. #include <shlobj.h>
  9.  
  10. #ifdef _PSEUDO_DEBUG
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. extern char str_num_classes[256];
  16. extern char str_get_class_desc[512];
  17. char *buf_img3=0;
  18. extern BITMAPINFO bmi;
  19.  
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CCustom3Dlg dialog
  22.  
  23.  
  24. CCustom3Dlg::CCustom3Dlg()
  25.     : CAppWizStepDlg(CCustom3Dlg::IDD)
  26. {
  27.     //{{AFX_DATA_INIT(CCustom3Dlg)
  28.         // NOTE: the ClassWizard will add member initialization here
  29.     //}}AFX_DATA_INIT
  30. }
  31.  
  32.  
  33. void CCustom3Dlg::DoDataExchange(CDataExchange* pDX)
  34. {
  35.     CAppWizStepDlg::DoDataExchange(pDX);
  36.     //{{AFX_DATA_MAP(CCustom3Dlg)
  37.     DDX_Control(pDX, IDC_FLYSDKPATH, m_flysdkpath);
  38.     //}}AFX_DATA_MAP
  39. }
  40.  
  41. // This is called whenever the user presses Next, Back, or Finish with this step
  42. //  present.  Do all validation & data exchange from the dialog in this function.
  43. BOOL CCustom3Dlg::OnDismiss()
  44. {
  45.     if (!UpdateData(TRUE))
  46.         return FALSE;
  47.  
  48.     char str[256];
  49.  
  50.     m_flysdkpath.GetWindowText(str,255);
  51.     Flypluginaw.m_Dictionary["FLYSDKPATH"]=str;
  52.  
  53.     return TRUE;
  54. }
  55.  
  56. BEGIN_MESSAGE_MAP(CCustom3Dlg, CAppWizStepDlg)
  57.     //{{AFX_MSG_MAP(CCustom3Dlg)
  58.     ON_WM_PAINT()
  59.     ON_BN_CLICKED(IDC_BROWSEFLY, OnBrowsefly)
  60.     //}}AFX_MSG_MAP
  61. END_MESSAGE_MAP()
  62.  
  63.  
  64. /////////////////////////////////////////////////////////////////////////////
  65. // CCustom3Dlg message handlers
  66.  
  67. void CCustom3Dlg::OnPaint() 
  68. {
  69.     CPaintDC dc(this); // device context for painting
  70.     
  71.     RECT rect;
  72.     GetClientRect(&rect);
  73.  
  74.     CBrush brush(RGB(96,96,96));
  75.     rect.right=180;
  76.     dc.FillRect(&rect,&brush);
  77.  
  78.     dc.SelectObject(GetStockObject(BLACK_PEN));
  79.  
  80.     dc.MoveTo(rect.right,0);
  81.     dc.LineTo(rect.right,rect.bottom);
  82.  
  83.     if (buf_img3==0)
  84.     {
  85.     HRSRC res=FindResource(hInst,"IMG3","TEMPLATE");
  86.     if (res)
  87.         {
  88.         HGLOBAL hg=LoadResource(hInst,res);
  89.         if (hg)
  90.             {
  91.             buf_img3=(char *)LockResource(hg);
  92.             if (buf_img3)
  93.                 {
  94.                 bmi.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
  95.                 bmi.bmiHeader.biWidth=128;
  96.                 bmi.bmiHeader.biHeight=128;
  97.                 bmi.bmiHeader.biPlanes=1;
  98.                 bmi.bmiHeader.biBitCount=24;
  99.                 bmi.bmiHeader.biCompression=BI_RGB;
  100.                 bmi.bmiHeader.biSizeImage=0;
  101.                 bmi.bmiHeader.biXPelsPerMeter=3600;
  102.                 bmi.bmiHeader.biYPelsPerMeter=3600; 
  103.                 bmi.bmiHeader.biClrUsed=0;     
  104.                 bmi.bmiHeader.biClrImportant=0; 
  105.                 }
  106.             }
  107.         }
  108.     }
  109.     if (buf_img3)
  110.         SetDIBitsToDevice(dc.m_hDC,
  111.             rect.right/2-64,32,128,128,
  112.             0,0,0,128,
  113.             &buf_img3[18],&bmi,DIB_RGB_COLORS);
  114. }
  115.  
  116. void CCustom3Dlg::OnBrowsefly() 
  117. {
  118.     BROWSEINFO bi;
  119.     char Buffer[MAX_PATH];
  120.     LPITEMIDLIST pidlBrowse;
  121.     LPMALLOC ppMalloc;
  122.     
  123.     SHGetMalloc( &ppMalloc );
  124.  
  125.     bi.hwndOwner = m_hWnd;
  126.     bi.pidlRoot = 0;
  127.     bi.pszDisplayName = Buffer;
  128.     bi.lpszTitle = "Select the Fly3D SDK folder";
  129.     bi.ulFlags = BIF_RETURNONLYFSDIRS;
  130.     bi.lpfn = NULL;
  131.     bi.lParam = 0;
  132.  
  133.     pidlBrowse = SHBrowseForFolder(&bi);
  134.  
  135.     if (pidlBrowse != NULL) 
  136.         {  
  137.         if (SHGetPathFromIDList(pidlBrowse, Buffer)) 
  138.             {
  139.             if (Buffer[0]!=0)
  140.                 if (Buffer[strlen(Buffer)-1]!='\\')
  141.                     strcat(Buffer,"\\");
  142.             m_flysdkpath.SetWindowText(Buffer);
  143.             }
  144.         ppMalloc->Free(pidlBrowse);
  145.         }
  146. }
  147.  
  148. BOOL CCustom3Dlg::OnInitDialog() 
  149. {
  150.     CAppWizStepDlg::OnInitDialog();
  151.  
  152.     m_flysdkpath.SetWindowText(Flypluginaw.m_Dictionary["FLYSDKPATH"]);
  153.     
  154.     return TRUE;
  155. }
  156.